/*
 * Copyright (c) 2011 Obix Labs Limited
 * Redistribution and use in source and binary forms, 
 * with or without modification, are permitted provided 
 * that the following conditions are met:
 * 
 * 		Redistribution of source code must retain the above 
 * 		copyright notice, this list of conditions and the 
 * 		following disclaimer.
 *
 * 		Redistribution in binary form must reproduce the 
 * 		above copyright notice, this list of conditions 
 * 		and the following disclaimer in the documentation 
 * 		and/or other materials provided with the distribution.
 * 
 * 	THIS SOFTWARE IS PROVIDED "AS IS," WITHOUT A WARRANTY OF 
 * 	ANY KIND. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS 
 * 	AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, 
 * 	FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, 
 * 	ARE HEREBY EXCLUDED. OBIX LABS LIMITED ("Obix Labs") AND ITS 
 * 	LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE 
 * 	AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR 
 * 	ITS DERIVATIVES. IN NO EVENT WILL Obix Labs OR ITS LICENSORS BE 
 * 	LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, 
 * 	INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE 
 * 	DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF 
 * 	LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS 
 * 	SOFTWARE, EVEN IF Obix Labs HAS BEEN ADVISED OF THE POSSIBILITY OF 
 * 	SUCH DAMAGES.
 */
package com.obixlabs.commons.security;

import com.obixlabs.commons.util.CharacterSource;

/**
 * <p>
 * A {@link PasswordRequirement password rule} which requires that 
 * a password to contain a specified minimum number of numeric 
 * characters.
 * </p>
 */
public class MinNumericCharsPasswordRequirement extends AbstractCharPresencePasswordRequirement
{
	/**
	 * <p>
	 * Proxy to parent constructor 
	 * {@link AbstractCharPresencePasswordRequirement#AbstractCharPresencePasswordRequirement()}.
	 * </p>
	 */
	public MinNumericCharsPasswordRequirement()
	{super();}
	
	/**
	 * <p>
	 * Proxy to parent constructor 
	 * {@link AbstractCharPresencePasswordRequirement#AbstractCharPresencePasswordRequirement(int)}. 
	 * </p>
	 * 
	 * @param minimumRequiredChars See {@link AbstractCharPresencePasswordRequirement#AbstractCharPresencePasswordRequirement(int)}
	 * for details.
	 */
	public MinNumericCharsPasswordRequirement(int minimumRequiredChars)
	{super(minimumRequiredChars);}
	

	/**
	 * <p>
	 * Proxy to parent constructor 
	 * {@link AbstractCharPresencePasswordRequirement#AbstractCharPresencePasswordRequirement(CharacterSource, int, int)}.
	 * </p>
	 * 
	 * @param characterSource
	 *            See
	 *            {@link AbstractCharPresencePasswordRequirement#AbstractCharPresencePasswordRequirement(CharacterSource, int, int)
	 *            proxied parent constructor} for details.
	 * @param prime 
	 *            See
	 *            {@link AbstractCharPresencePasswordRequirement#AbstractCharPresencePasswordRequirement(CharacterSource, int, int)
	 *            proxied parent constructor} for details.
	 *            
	 * @param minimumRequiredChars 
	 * 			  See
	 *            {@link AbstractCharPresencePasswordRequirement#AbstractCharPresencePasswordRequirement(CharacterSource, int, int)
	 *            proxied parent constructor} for details.
.            
	 */
	public MinNumericCharsPasswordRequirement(
			CharacterSource characterSource, int prime, int minimumRequiredChars)
	{super(characterSource, prime, minimumRequiredChars);}

	/**
	/**
	 * <p>
	 * Proxy to parent constructor 
	 * {@link AbstractCharPresencePasswordRequirement#AbstractCharPresencePasswordRequirement(CharacterSource, int)}.
	 * </p>
	 * 
	 * @param characterSource
	 *            See
	 *            {@link AbstractCharPresencePasswordRequirement#AbstractCharPresencePasswordRequirement(CharacterSource, int)
	 *            proxied parent constructor} for details.
	 *            
	 * @param minimumRequiredChars 
	 *            See
	 *            {@link AbstractCharPresencePasswordRequirement#AbstractCharPresencePasswordRequirement(CharacterSource, int)
	 *            proxied parent constructor} for details.
	 */
	public MinNumericCharsPasswordRequirement(CharacterSource characterSource, 
												int minimumRequiredChars)
	{super(characterSource, minimumRequiredChars);}

	@Override
	public boolean characterSatisfiesRequirement(char character)
	{ return Character.isDigit(character); }

	@Override
	public char generateCharacterToSatisfyRequirement()
	{ return getCharacterSource().nextNumericChar(); }

	@Override
	public String getDescription()
	{ return "At least one numeric character."; }
}